﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Con Descuento</title>

    <script type="text/javascript" src="~/Contenido/jquery/jquery-2-1-1.js"></script>
    <script type="text/javascript" src="~/Contenido/plugins/moment-with-locales.js"></script>
    <script type="text/javascript" src="~/Contenido/bootstrap/bootstrap.js"></script>
    <script type="text/javascript" src="~/Contenido/bootstrap/bootstrap-datetimepicker.js"></script>
    <link rel="stylesheet" href="~/Contenido/bootstrap/bootstrap.css" />
    <link rel="stylesheet" href="~/Contenido/bootstrap/bootstrap-datetimepicker.css" />
    <link rel="stylesheet" href="~/Contenido/bootstrap/bootstrap-theme.css" />
    <link rel="stylesheet" href="~/Contenido/bootstrap/bootstrap-switch.css" />

    <script type="text/javascript" src="~/Contenido/bootstrap/bootstrap-switch.js"></script>

    <script type="text/javascript" src="~/Contenido/plugins/modernizr-1.7.min.js"></script>
    <link rel="stylesheet" href="~/Contenido/Sitio/css/ConDes.css" />
    <link rel="stylesheet" href="~/Contenido/Sitio/css/Tienda.css" />

    @*BXSLIDER*@
    <script src="~/Contenido/bxslider/jquery.bxslider.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="~/Contenido/bxslider/jquery.bxslider.css" />

    <script type="text/javascript">
        $(document).ready(function () {
            $("#finalizarCompra").hide();
            cargarMenuPrincipal();
            actualizarCantidadCarrito();
            EventBinder($("#finalizarCompra"), "click", irPagar);
            EventBinder($("#botonBuscar"), "click", buscar);
            EventBinder($("#parametroBusqueda"), "keyup", buscarEnter);
        });

        function EventBinder(objectToBind, eventName, eventHandler, ignoreInTouch) {
            if (Modernizr.touch) {
                if (ignoreInTouch)
                    return;

                if (eventName == "mouseleave")
                    objectToBind.bind("focusout", eventHandler);
                else if (eventName == "focusout")
                    objectToBind.bind("focusout", eventHandler);
                else
                    objectToBind.bind("touchstart", eventHandler);
            }
            //On touch devices, we could also have a mouse plugged in.
            objectToBind.bind(eventName, eventHandler);
        }

        function EventUnBinder(objectToUnBind, eventName, eventHandler) {
            if (Modernizr.touch) {
                objectToUnBind.unbind("touchstart", eventHandler);
            }

            objectToUnBind.unbind(eventName, eventHandler);
        }

        function cargarMenuPrincipal() {
            $.ajax({
                url: '@Url.Content("~/Home/MenuPrincipal")',
                success: function (data) {
                    $("#contenedorMenuPrincipal").html(data);
                }
            });
        }

        function actualizarCantidadCarrito() {
            $.ajax({
                url: '@Url.Content("~/Tienda/ObtenerCantidadMiCompra")',
                success: function (data) {
                    if (data.Cantidad == 0)
                        $("#finalizarCompra").hide();
                    else
                        $("#finalizarCompra").show();

                    $("#contadorProductos").text(data.Cantidad);
                }
            });
        }

        function irPagar() {
            window.location = '@Url.Content("~/Tienda/Pagar")';
        }

        function buscar() {
            var pija = $("#parametroBusqueda").val();
            if (pija.length == 0)
                return;

            window.location = '@Url.Content("~/Tienda/Buscar/?parametro=")' + pija;
        }

        function buscarEnter(e) {
            if (e.keyCode == 13) {
                buscar();
            }
        }
    </script>
</head>
<body>
    <script>
    (function (i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date(); a = s.createElement(o),
        m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
    })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');

    ga('create', 'UA-81210168-1', 'auto');
    ga('send', 'pageview');

    </script>
    <header class="cabecera navbar-fixed-top">
        <div class="container contenedorNavegador">
            <div class="row">
                <div class="col-md-3">
                    <a href="@Url.Content("~/")"><img class="conDesLogo" src="~/Contenido/Sitio/Imagenes/ConDescuentoLogo.png" /></a>
                </div>
                <div class="col-lg-6 col-md-5">
                    <div class="input-group">
                        <input id="parametroBusqueda" type="text" class="form-control" placeholder="Buscar..." />
                        <span class="input-group-btn">
                            <button id="botonBuscar" class="btn btn-primary">
                                <img class="lupaBusqueda" alt="Lupa" src="~/Contenido/Sitio/Imagenes/LupaBlanca.png" />
                            </button>
                        </span>
                    </div>
                </div>
                <div class="col-lg-3 col-md-4">
                    <div class="contenedorCarro">
                        <img src="~/Contenido/Sitio/Imagenes/icon-header-cart.png" />
                        <label id="contadorProductos">0</label>
                    </div>
                    <button id="finalizarCompra" class="btn btn-success">Finalizar Compra</button>
                </div>
            </div>
        </div>
    </header>
    <div class="nav-category-menu">
        <div class="container">
            <nav id="contenedorMenuPrincipal" class="btn-group">
                
            </nav>
        </div>
    </div>
    <div class="container">
        @RenderBody()
    </div>
    <div class="pie">
        <div class="container">
            <span>© 2016 Con Descuento, todos los derechos reservados</span>
        </div>
    </div>
</body>
</html>
